package hng.controller.admin;


import hng.dto.BannerDTO;
import hng.mapper.BannerMapper;
import hng.model.BannerDO;
import hng.model.LoginUser;
import hng.service.admin.BannerService;
import hng.util.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 轮播图表 前端控制器
 * </p>
 *
 * @author 告白
 * @since 2024-06-27
 */
@RestController
@RequestMapping("/admin/banner")
public class BannerController {
    @Autowired(required = false)
    private BannerService bannerService;

    /**
     *  添加轮播图
     */
    @PostMapping("/add")
    public JsonData add(@RequestBody BannerDTO bannerDTO) {
        bannerService.add(bannerDTO);
        return JsonData.buildSuccess();
    }
    /**
     *  添加轮播图
     */
    @GetMapping("/del")
    public JsonData del(@RequestParam("id") Integer id) {
        bannerService.del(id);
        return JsonData.buildSuccess();
    }
    /**
     *  修改轮播图
     *
     */
    @PostMapping("/update")
    public JsonData update(@RequestBody BannerDTO bannerDTO) {
        bannerService.update(bannerDTO);
        return JsonData.buildSuccess();
    }
    /**
     *  查询轮播图
     */
    @GetMapping("/list")
    public JsonData list(){
        List<BannerDO> bannerList = bannerService.bannerList();
        return JsonData.buildSuccess(bannerList);
    }

}

